<template>
	<div class="act-task-reward">
		<sc-form-table ref="table" v-model="taskList" :addTemplate="addTemplate" drag-sort placeholder="暂无数据">
			<el-table-column class-name="custom-cell" label="&nbsp;任务信息">
				<template #default="scope">
					<el-descriptions :column="1" border size="small"> <!--direction="vertical"-->
						<el-descriptions-item label="任务类型">
							<el-select @change="selectChange($event,scope.row)" size="size"
								v-model="scope.row.task_type">
								<el-option label="介绍新客消费满50" value="hm_invite_visit_50">

								</el-option>
							</el-select>
						</el-descriptions-item>
						<el-descriptions-item label="任务标题">
							<el-input placeholder="任务标题" size="size" v-model="scope.row.task_title">
							</el-input>
						</el-descriptions-item>
						<el-descriptions-item label="任务说明">
							<el-input placeholder="任务说明" type="textarea" autosize size="size"
								v-model="scope.row.task_description">
							</el-input>
						</el-descriptions-item>
						<el-descriptions-item label="任务奖励">
							<el-input placeholder="奖励的积分或者活动金" type="number" :min="1" size="size"
								v-model="scope.row.task_reward">
							</el-input>
						</el-descriptions-item>
						<el-descriptions-item label="每天限次">
							<el-input placeholder="每天最多能执行的次数" type="number" :min="0" size="size"
								v-model="scope.row.task_daily_limit">
							</el-input>
						</el-descriptions-item>
						<el-descriptions-item label="需达成次数">
							<el-input placeholder="总共需要达成的次数" type="number" :min="0" size="size"
								v-model="scope.row.task_required_count">
							</el-input>
						</el-descriptions-item>
						<el-descriptions-item label="执行描述">
							<el-input size="size" v-model="scope.row.task_go_text">
							</el-input>
						</el-descriptions-item>
						<el-descriptions-item label="领取描述">
							<el-input size="size" v-model="scope.row.task_go_claim_text">
							</el-input>
						</el-descriptions-item>
						<el-descriptions-item label="完成描述">
							<el-input size="size" v-model="scope.row.task_completed_text">
							</el-input>
						</el-descriptions-item>
					</el-descriptions>
				</template>
			</el-table-column>
		</sc-form-table>
	</div>
</template>

<script>
	import {
		defineComponent
	} from 'vue';
	import {
		copy
	} from '@form-create/utils/lib/extend';

	export default defineComponent({
		name: 'taskRewardList',
		emits: ['update:modelValue', 'change'],
		data() {
			return {
				addTemplate: {
					task_type: '',
					task_name: '',
					task_description: '',
					task_reward: 0,
					task_daily_limit: 0,
					task_required_count: 0,
					task_go_text: '去完成',
					task_go_claim_text: '去领取',
					task_completed_text: '已完成',
				}
			}
		},
		components: {

		},
		props: {
			modelValue: [Array]
		},
		inject: ['designer'],
		computed: {
			taskList: {
				get() {
					return this.modelValue
				},
				set(val) {
					this.$emit('update:modelValue', val);
				}
			},
		},
		methods: {
			selectChange(e, row) {
				switch (e) {
					case 'hm_invite_visit_50':
						row.task_title = '邀请好友消费';
						row.task_description = '好友进入邀请链接,参加完善信息后到院消费';
						row.task_reward = 0;
						row.task_daily_limit = 0;
						row.task_required_count = 0;
						row.task_go_text = '去邀请';
						row.task_go_claim_text = '去领取';
						row.task_completed_text = '已完成';
						break;
					default:
						break;
				}
			}
		}
	});
</script>

<style scoped lang="scss">
	.act-task-reward {
		width: 100%;
	}
</style>
